import time

from selenium.webdriver.common.by import By
from Base.Base import Base

class Page1(Base):

    # 点击月考
    click_yuekao_loc = (By.XPATH, '/html/body/div[1]/div/section/aside/ul/li[1]/div')
    def click_yuekao(self):
        self.click(self.click_yuekao_loc)

    # 点击用户登录
    click_login_loc = (By.XPATH, '/html/body/div[1]/div/section/aside/ul/li/ul/li[8]')
    def click_login(self):
        self.click(self.click_login_loc)
    # 输入用户名
    send_user_log = (By.XPATH, '/html/body/div[1]/div/section/section/main/div/div[2]/div[1]/div/input')
    def send_user(self, username):
        self.send_keys(self.send_user_log, username)
    # 输入密码
    send_password_log = (By.XPATH, '/html/body/div[1]/div/section/section/main/div/div[2]/div[2]/div/input')
    def send_password(self, password):
        self.send_keys(self.send_password_log, password)
    # 点击登录按钮
    click_login_button_loc = (By.XPATH, '/html/body/div[1]/div/section/section/main/div/div[2]/button')
    def click_login_button(self):
        self.click(self.click_login_button_loc)


    # 业务逻辑
    def Item_user_login(self,username, password):
        self.open_url('http://localhost:8081/')
        time.sleep(2)
        self.click_yuekao()
        self.click_login()
        self.send_user(username)
        self.send_password(password)
        self.click_login_button()
        time.sleep(2)



